#coding=utf-8
__author__ = 'Meteor'


from base.webelement import Base

'''
封装登录类：该类继承与Base类
该类中提供以下方法：
    输入用户名
    输入密码
    是否记住密码
    点击注册
    点击确定
    获取提示框信息
'''
from selenium.webdriver.common.by import By
class Login_page(Base):


    def input_name(self,name):
        '''
        输入用户名
        :param name: 登录时的登录名（str）
        :return: 
        '''
        self.send_keys((By.CSS_SELECTOR,"#loginName"),name)

    def input_password(self,password):
        '''
        输入登录时的密码
        :param password: 登录密码（str）
        :return: 
        '''
        self.send_keys((By.ID,"password"),password)

    def is_auto_login(self):
        '''
        点击记住密码
        :return: 
        '''
        self.click((By.ID,"rememberMe"))


    def click_regit_user(self):
        '''
        点击注册用户
        :return: 
        '''
        self.click((By.LINK_TEXT,"注册租户"))

    def click_login_button(self):
        '''
        点击登录按钮
        :return: 
        '''
        self.click((By.CSS_SELECTOR,"#formLogin > div:nth-child(4) > div > div > span > button"))

    def get_name_is_null_message(self):
        '''
        获取用户名错误时的提示信息
        :return: 元素的文本内容
        '''
        #body > div.ant-notification.ant-notification-topRight > span > div > div > div > div.ant-notification-notice-description
        return self.get_text((By.CSS_SELECTOR,"#formLogin > div:nth-child(1) > div > div > div"))

    def get_password_is_null_message(self):
        '''
        获取密码错误时的提示信息
        :return: 元素的文本内容
        '''
        return self.get_text((By.CSS_SELECTOR,"#formLogin > div:nth-child(2) > div > div > div"))

    def get_login_error_message(self):
        return self.get_text((By.CSS_SELECTOR,"body > div.ant-notification.ant-notification-topRight > span > div > div > div > div.ant-notification-notice-description"))


    def login(self,name,password):
        #将整个登录封装成一个关键字
        self.input_name(name)
        self.input_password(password)
        self.click_login_button()

class Index_page(Base):
    def get_login_message(self):
        '''
        获取用户登录成功后的提示信息
        :return: 元素的文本内容
        '''
        return self.get_text((By.CSS_SELECTOR,"div > div > div > div.ant-notification-notice-description"))

    def click_base_info(self):
        '''
        点击基本资料
        :return: 
        '''
        self.click((By.CSS_SELECTOR,"#app > section > aside > div > ul > li:nth-child(11) > div > span > span"))

    def click_reposit_info(self):
        '''
        点击仓库信息
        :return: 
        '''
        self.click((By.CSS_SELECTOR,"#app > section > aside > div > ul > li.ant-menu-submenu.ant-menu-submenu-inline.ant-menu-submenu-open > ul > li:nth-child(4) > a"))

    def close_introjs_skipbutton(self):
        self.click((By.CSS_SELECTOR,"body > div.introjs-tooltipReferenceLayer > div > div.introjs-tooltip-header > a"))



